import os
from dotenv import load_dotenv, find_dotenv
from pydantic import BaseSettings

# 加载环境变量
_ = load_dotenv(find_dotenv())

class Settings(BaseSettings):
    """应用配置设置"""
    
    # 基础配置
    app_name: str = "WebAPI - 公交站查询系统"
    version: str = "1.0.0"
    debug: bool = False
    
    # 服务器配置
    host: str = "0.0.0.0"
    port: int = 8080
    
    # 数据库配置
    db_host: str = os.getenv("DB_HOST", "localhost")
    db_user: str = os.getenv("DB_USER", "root") 
    db_password: str = os.getenv("DB_PASSWORD", "")
    db_database: str = os.getenv("DB_DATABASE", "webapi")
    
    # AI服务配置
    openai_api_key: str = os.getenv("OPENAI_API_KEY", "")
    dashscope_api_key: str = os.getenv("DASHSCOPE_API_KEY", "")
    coze_api_token: str = os.getenv("COZE_API_TOKEN", "")
    coze_api_space_id: str = os.getenv("COZE_API_SPACE_ID", "")
    
    # 百度AI配置
    aip_api_key: str = os.getenv("AIP_API_KEY", "")
    aip_secret_key: str = os.getenv("AIP_SECRET_KEY", "")
    
    # 微信配置
    wechat_appid: str = os.getenv("WE_CHAT_APPID", "")
    wechat_app_secret: str = os.getenv("WE_CHAT_APP_SECRET", "")
    
    # 聚合数据API密钥
    juhe_api_key: str = os.getenv("JUHE_API_KEY", "")
    
    # 文件上传配置
    upload_dir: str = "uploads"
    max_file_size: int = 10 * 1024 * 1024  # 10MB
    
    class Config:
        env_file = ".env"

# 创建全局设置实例
settings = Settings()
